<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of HtmlHelper
 *
 * @author Zelic
 */
class Lib_Helper_TableHelper {
    static function createTable($class, $data, $alias = null){
        $fields = array_keys($data[0]);
        echo '<table class="'.$class.'">';
        echo '<thead><tr>';
        foreach ($fields as $field){
            if (isset($alias["$field"])){
                echo '<th>'.$alias["$field"].'</th>';
            } else {
                echo '<th>'.$field.'</th>';
            }
        }
        echo '</tr></thead>';
        echo '<tbody>';
        foreach ($data as $row){
            echo '<tr>';
            $values = array_values($row);
            foreach ($values as $value){
                echo '<td>'.$value.'</td>';
            }
            echo '</tr>';
        }
        echo '</tbody>';
        echo '</table>';
    }
}

?>
